package com.jic.member.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberGradeOrderRecharge;
import com.jic.member.mapper.MememberGradeOrderRechargeMapper;
import com.jic.member.service.MememberGradeOrderRechargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 会员等级管理-成长值规则-下单-充值赠送表
 * @author : 
 * @email : 
 * @since : 2020-04-02 08:03:51
 * @version : v1.0.0
 */
@Service
public class MememberGradeOrderRechargeServiceImpl implements MememberGradeOrderRechargeService{

    @Autowired
    private MememberGradeOrderRechargeMapper mememberGradeOrderRechargeMapper;

    @Override
    public long insert(MememberGradeOrderRecharge mememberGradeOrderRecharge) {
        long flag = mememberGradeOrderRechargeMapper.insert(mememberGradeOrderRecharge);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberGradeOrderRechargeMapper.delete(id);
    }

    @Override
    public long update(MememberGradeOrderRecharge mememberGradeOrderRecharge) {
        return mememberGradeOrderRechargeMapper.update(mememberGradeOrderRecharge);
    }

    @Override
    public MememberGradeOrderRecharge queryByPrimaryKey(Long orderId){
        return mememberGradeOrderRechargeMapper.queryByPrimaryKey(orderId);
    }

    @Override
    public List<MememberGradeOrderRecharge> query(MememberGradeOrderRecharge mememberGradeOrderRecharge){
        return mememberGradeOrderRechargeMapper.query(mememberGradeOrderRecharge);
    }

    @Override
    public PageResult<MememberGradeOrderRecharge> queryPage(MememberGradeOrderRecharge mememberGradeOrderRecharge, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberGradeOrderRecharge> list = mememberGradeOrderRechargeMapper.queryPage(startIndex, pageQuery.getLimit(), mememberGradeOrderRecharge);
        long count = mememberGradeOrderRechargeMapper.queryPageCount(mememberGradeOrderRecharge);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}